﻿<UserControl 
    xmlns:Controls1="clr-namespace:Microsoft.Internal.Pivot.Controls;assembly=System.Windows.Controls.Pivot"  
    xmlns:Controls="clr-namespace:Microsoft.Internal.Pivot.Controls;assembly=System.Windows.Controls.Pivot"  
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:pivot1="clr-namespace:System.Windows.Controls.Pivot;assembly=System.Windows.Controls.Pivot"
    xmlns:local="clr-namespace:PivotViewerBase"
    xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:Web="clr-namespace:PivotViewerBase.Web" 
    xmlns:pivot="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
    mc:Ignorable="d"
    x:Class="PivotViewerBase.MainPage"
    x:Name="usrCtl">

    <UserControl.Resources>
        <local:ForegroundColorValueConverter  x:Key="fgConv" />
        <local:BackgroundColorValueConverter  x:Key="bgConv" />
        <local:YearToDateConverter x:Key="ytdConv"/>

        <local:LegendList x:Key="BackgroundLegend">
            <local:Legend LegendName="Specialty -"  />
            <local:Legend LegendName="Mountain"  />
            <local:Legend LegendName="Road"  />
            <local:Legend LegendName="Touring"  />
        </local:LegendList>


        <local:LegendList x:Key="ForegroundLegend">
            <local:Legend LegendName="Biz Type -"  />
            <local:Legend LegendName="BM"  />
            <local:Legend LegendName="BS"  />
            <local:Legend LegendName="OS"  />
        </local:LegendList>

        <riaControls:DomainDataSource x:Name="vStoreWithDemographicDomainDataSource" 
            AutoLoad="True" Height="0" LoadedData="vStoreWithDemographicDomainDataSource_LoadedData_2"
            QueryName="GetVStoreWithDemographicsQuery" Width="0" 
            d:DesignData="{d:DesignInstance Web:vStoreWithDemographic, CreateList=true}">
            <riaControls:DomainDataSource.DomainContext>
                <Web:AdventureWorksDomainContext/>
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource>

        <riaControls:DomainDataSource x:Name="vStoreWithDemographicDomainDataSource2" 
            AutoLoad="True" Height="0" LoadedData="vStoreWithDemographicDomainDataSource_LoadedData_2"
            QueryName="GetVStoreWithDemographicsQuery" Width="0" 
            d:DesignData="{d:DesignInstance Web:vStoreWithDemographic, CreateList=true}">
            <riaControls:DomainDataSource.DomainContext>
                <Web:AdventureWorksDomainContext/>
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource>

        <Style x:Key="basicAdorner" 
          TargetType="pivot:PivotViewerItemAdorner">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <pivot:PivotViewerDefaultItemAdorner
                    IsItemSelected="{Binding IsItemSelected, 
                RelativeSource={RelativeSource TemplatedParent}}"
              CommandsRequested="basicAdorner_CommandsRequested"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="90" />
        </Grid.RowDefinitions>

        <!--ItemsSource="{Binding Data, ElementName=vStoreWithDemographicDomainDataSource}" -->


        <!--<sdk:TabControl>
            <sdk:TabItem Header="Pivot">-->
        <toolkit:BusyIndicator IsBusy="True" VerticalAlignment="Center" HorizontalAlignment="Center"/>
        <pivot:PivotViewer x:Name="pViewer" ItemAdornerStyle="{StaticResource basicAdorner}" 
           ItemsSource="{Binding Data, ElementName=vStoreWithDemographicDomainDataSource}" 
             ViewChanged="pViewer_ViewChanged_1" TextOptions.TextFormattingMode="Display">
            <pivot:PivotViewer.ItemTemplates>
                <pivot:PivotViewerItemTemplate MaxWidth="300">
                    <Border Width="300" Height="300" 
                       Background="{Binding Specialty, Converter={StaticResource bgConv}}">
                        <TextBlock Text="{Binding NumberEmployees}" 
                            FontSize="90"
                            FontWeight="Bold"
                            Foreground="{Binding BusinessType, Converter={StaticResource fgConv}}"
                            HorizontalAlignment="Center" 
                            VerticalAlignment="Center" />
                    </Border>
                </pivot:PivotViewerItemTemplate>
                <pivot:PivotViewerItemTemplate>
                    <Grid Width="800" Height="800" Background="LightGray">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="200"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Rectangle Fill="{Binding Specialty, Converter={StaticResource bgConv}}"/>
                        <StackPanel  Grid.Column="1">
                            <Grid Width="800" Height="800" Background="LightGray">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="300"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="50" />
                                    <RowDefinition Height="50" />
                                    <RowDefinition  Height="50"/>
                                    <RowDefinition  Height="50"/>
                                    <RowDefinition  Height="50"/>
                                </Grid.RowDefinitions>
                                <TextBlock Text="{Binding Name}" Grid.ColumnSpan="2" FontSize="36"
                                           Foreground="{Binding BusinessType, Converter={StaticResource fgConv}}"
                            FontWeight="Bold"
                            HorizontalAlignment="Left" 
                            VerticalAlignment="Center" />
                                <TextBlock Text="Specialty" Grid.Row="1" FontSize="36"
                            HorizontalAlignment="Left" 
                            VerticalAlignment="Bottom" />
                                <TextBlock Text="{Binding Specialty}" Grid.Row="1" Grid.Column="1" FontSize="36"
                            HorizontalAlignment="Left" 
                            VerticalAlignment="Bottom" />
                                <TextBlock Text="Annual Revenue"  Grid.Row="2" 
                            FontSize="36"
                            VerticalAlignment="Bottom"
                            HorizontalAlignment="Left"/>
                                <TextBlock Text="{Binding AnnualRevenue, StringFormat=C}"  Grid.Row="2" Grid.Column="1" 
                            FontSize="36"
                            VerticalAlignment="Bottom"
                            HorizontalAlignment="Left"/>
                                <TextBlock Text="Annual Sales" Grid.Row="3" Grid.Column="0" 
                            FontSize="36" 
                            VerticalAlignment="Bottom"
                            HorizontalAlignment="Left"/>
                                <TextBlock Text="{Binding AnnualSales, StringFormat=c}" Grid.Row="3" Grid.Column="1" 
                            FontSize="36" 
                            VerticalAlignment="Bottom"
                            HorizontalAlignment="Left"/>
                                <TextBlock Text="Business Type" Grid.Row="4" Grid.Column="0" 
                            FontSize="36" 
                            VerticalAlignment="Bottom"
                            HorizontalAlignment="Left"/>
                                <TextBlock Text="{Binding BusinessType}" Grid.Row="4" Grid.Column="1" 
                            FontSize="36" 
                            VerticalAlignment="Bottom"
                            HorizontalAlignment="Left"/>
                            </Grid>
                        </StackPanel>
                    </Grid>
                </pivot:PivotViewerItemTemplate>
            </pivot:PivotViewer.ItemTemplates>
            <pivot:PivotViewer.PivotProperties>
                <!--<pivot:PivotViewerNumericProperty 
                        Id="Id" 
                        Options="None" 
                        Binding="{Binding Id}"/>-->

                <pivot:PivotViewerStringProperty 
                        Id="Specialty"
                        DisplayName="Bike Specialty"
                        Options="CanFilter,CanSearchText" 
                        Binding="{Binding Specialty}"/>
                <pivot:PivotViewerNumericProperty 
                        Id="AnnualRevenue"
                        DisplayName="Annual Revenue"
                        Options="CanFilter,CanSearchText" 
                        Binding="{Binding AnnualRevenue}"/>
                <pivot:PivotViewerNumericProperty
                        Id="AnnualSales" 
                        DisplayName="Annual Sales"
                        Options="CanFilter" 
                        Binding="{Binding AnnualSales}"/>
                <pivot:PivotViewerNumericProperty 
                        Id="NumberEmployees" 
                        DisplayName="Number Employees"
                        Options="CanFilter" 
                        Binding="{Binding NumberEmployees}"/>
                <pivot:PivotViewerDateTimeProperty 
                        Id="YearOpened" 
                        DisplayName="Year Opened"
                        Options="CanFilter" 
                        Binding="{Binding YearOpened, Converter={StaticResource ytdConv}}"/>
                <pivot:PivotViewerStringProperty 
                        Id="BizType" 
                        DisplayName="Business Type"
                        Options="CanFilter" 
                        Binding="{Binding BusinessType}"/>
                <pivot:PivotViewerStringProperty 
                        Id="BankName" 
                        DisplayName="Bank Name"
                        Options="CanFilter" 
                        Binding="{Binding BankName}"/>
            </pivot:PivotViewer.PivotProperties>
        </pivot:PivotViewer>
        <Grid  Grid.Row="1" Background="#FFF2F2F2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <StackPanel Orientation="Horizontal"  Grid.Column="1" Margin="5" HorizontalAlignment="Right" >
                <ListBox ItemsSource="{StaticResource BackgroundLegend}" Background="#FFF2F2F2" Margin="5,0,0,0">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Rectangle Width="12" Height="12" Fill="{Binding LegendName, Converter={StaticResource bgConv}}"  />
                                <sdk:Label Margin="5,0,0,0"  Height="12" Content="{Binding LegendName}" Grid.Column="1" FontSize="9" VerticalAlignment="Top" />

                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <ListBox ItemsSource="{StaticResource ForegroundLegend}" Background="#FFE6E6E6" Margin="5,0,0,0">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Ellipse Width="8" Height="8" Fill="{Binding LegendName, Converter={StaticResource fgConv}}"  />
                                <sdk:Label Margin="5,0,0,0"  Height="12" Content="{Binding LegendName}" Grid.Column="1" FontSize="9" VerticalAlignment="Top" />

                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </StackPanel>
            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="5,0,0,0"  Background="Transparent" Grid.ColumnSpan="2">
                <StackPanel>
                    <ToggleButton Width="50"  Height="50" Margin="5,0,0,0" VerticalAlignment="Center"  ClickMode="Press" >
                        <Image Source="/PivotViewerBase;component/Images/Pivotviewer Thumbnail 50.png" Width="50" Height="50"/>
                    </ToggleButton>
                    <sdk:Label Content="Hello" HorizontalAlignment="Center" />
                </StackPanel>
                <StackPanel>
                    <ToggleButton Content="World" Width="50" Height="50" Margin="5,0,0,0" VerticalAlignment="Center" ClickMode="Press" />
                    <sdk:Label Content="World" HorizontalAlignment="Center"  />
                </StackPanel>
            </StackPanel>


        </Grid>
        <!--</sdk:TabItem>
            <sdk:TabItem Header="Table">

            </sdk:TabItem>
        </sdk:TabControl>-->


        <!--
        <sdk:DataGrid x:Name="vStoreWithDemographicDataGrid" AutoGenerateColumns="False" 
            ItemsSource="{Binding Data, ElementName=vStoreWithDemographicDomainDataSource}" 
                      Margin="0,275,175,-225" RowDetailsVisibilityMode="VisibleWhenSelected">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn x:Name="annualRevenueColumn" Binding="{Binding AnnualRevenue}" Header="Annual Revenue" Width="SizeToHeader"/>
                <sdk:DataGridTextColumn x:Name="annualSalesColumn" Binding="{Binding AnnualSales}" Header="Annual Sales" Width="SizeToHeader"/>
                <sdk:DataGridTextColumn x:Name="bankNameColumn" Binding="{Binding BankName}" Header="Bank Name" Width="SizeToHeader"/>
                <sdk:DataGridTextColumn x:Name="brandsColumn" Binding="{Binding Brands}" Header="Brands" Width="SizeToHeader"/>
                <sdk:DataGridTextColumn x:Name="businessEntityIDColumn" Binding="{Binding BusinessEntityID, Mode=OneWay}" Header="Business Entity ID" IsReadOnly="True" Width="SizeToHeader"/>
                <sdk:DataGridTextColumn x:Name="businessTypeColumn" Binding="{Binding BusinessType}" Header="Business Type" Width="SizeToHeader"/>
                <sdk:DataGridTextColumn x:Name="internetColumn" Binding="{Binding Internet}" Header="Internet" Width="SizeToHeader"/>
                <sdk:DataGridTextColumn x:Name="nameColumn" Binding="{Binding Name, Mode=OneWay}" Header="Name" IsReadOnly="True" Width="SizeToHeader"/>
                <sdk:DataGridTextColumn x:Name="numberEmployeesColumn" Binding="{Binding NumberEmployees}" Header="Number Employees" Width="SizeToHeader"/>
                <sdk:DataGridTextColumn x:Name="specialtyColumn" Binding="{Binding Specialty}" Header="Specialty" Width="SizeToHeader"/>
                <sdk:DataGridTextColumn x:Name="squareFeetColumn" Binding="{Binding SquareFeet}" Header="Square Feet" Width="SizeToHeader"/>
                <sdk:DataGridTextColumn x:Name="yearOpenedColumn" Binding="{Binding YearOpened}" Header="Year Opened" Width="SizeToHeader"/>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>
        -->
    </Grid>

</UserControl>

